<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
    <script src="js/axios.min.js"></script>
</head>
<body>
<div id="list">
    <input type="text" v-model="id">
    <input type="text" v-model="name">
    <input type="text" v-model="password">
    <input type="button" value="新建Manager" @click="addManager(id,name,password)">
    <br>
    <span v-for="i in list">
        {{i.id}} {{i.name}} {{i.password}} <input type="button" value="删除" @click="delManager(i.id,i.name)"><br>
    </span>
</div>
<script>
    var v = new Vue({
        el: "#list",
        data: {
            list: [],
            id: "",
            name: "",
            password: "",
        },
        methods: {
            show: function () {
                var that = this;
                axios.post("http://localhost:9090/all").then(
                    function (response) {
                        that.list = response.data
                    }
                )
            },
            delManager: function (id, name) {
                axios.post("http://localhost:9090/delete?id=" + id + "&name=" + name).then(
                    function (response) {
                        alert("success")
                        location.reload()
                    }
                )
            },
            addManager: function (id, name, password) {
                axios.post("http://localhost:9090/create?id=" + id + "&name=" + name + "&password=" + password).then(
                    function (response) {
                        alert("success")
                        location.reload()
                    }
                )
            }
        },
        mounted: function () {
            this.show()
        }
    })
</script>
</body>
</html>